#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@IDE     ：PyCharm 
@Author  ：kiway
@Date    ：2024/7/27 10:19 
"""

import asyncio
from abc import abstractmethod, ABCMeta
from .event import *
from ..logger import pretty_print
from multiprocessing import Queue


class BaseEngine(metaclass=ABCMeta):

    def __init__(self, engine_name, main_engine):
        self._msg_q = Queue()
        self.engine_name = engine_name
        self.main_engine = main_engine
        self._interval = 10

    def put_self_mq(self, event):
        self._msg_q.put(event)

    def put_event(self, event):
        self.main_engine.put_event(event)

    def start(self):
        self._start()
        pretty_print(f"{self.engine_name} 启动")

    def deliver_to_main_engine(self, event: Event):
        self.main_engine.put(event)

    @abstractmethod
    def _start(self):
        pass
